#pragma once

#include <EventLoopThread.h>
#include <vector>

class EventLoopThreadPool
{
    using ThreadInitCallback = std::function<void(EventLoop*)>;
public:
    EventLoopThreadPool(EventLoop* loop,const std::string& name = std::string());

    ~EventLoopThreadPool();
    
    void start(int n,ThreadInitCallback cb = ThreadInitCallback());

    EventLoop* getNextLoop();

    std::vector<EventLoop*> getAllLoops();

private:
    EventLoop* baseLoop_;
    std::string name_;
    int nThread_;
    std::vector<EventLoop*> loops_;
    std::vector<std::unique_ptr<EventLoopThread>> threads_;
    int nextLoop_;
    bool started_;
};